package com.itheima.controller;

import com.itheima.domain.Student;
import com.itheima.service.ServiceStudentImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;

public class ControllerStudentImpl {
    private ServiceStudentImpl  service=new ServiceStudentImpl();

    @Test
    public void findAll(){
        ArrayList<Student> list1 = service.findAll();

        for (Student student : list1) {
            System.out.println(student);
        }
    }

    @Test
    public void findByID(){
        Student stu = service.findById(3);
        System.out.println(stu);

    }

    @Test
    public void insert(){

        Student stu = new Student(3, "何想", 23, new Date());
        int result = service.insert(stu);
        if (result!=0){
            System.out.println("插入成功！");
        }else {
            System.out.println("插入失败");
        }
    }

    @Test
    public void update(){
        Student stu = service.findById(3);
        System.out.println(stu);
        stu.setName("远思");
        System.out.println(stu);
        int result = service.update(stu);
        if (result!=0){
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }

    }

    @Test
    public void delete(){
        int result = service.delete(3);
        if (result!=0){
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }

    }
}
